#!/usr/bin/python
# -*- coding: utf-8 -*-
# @version        : 1.0
# @Create Time    : 2024/8/4 17:07
# @File           : task
# @IDE            : PyCharm
# @desc           : 描述

from datetime import datetime
from typing import Optional, Set

from sqlalchemy import ForeignKey, String, JSON, Integer, DateTime, Float, Text
from sqlalchemy.orm import Mapped, mapped_column, relationship

from db.db_base import BaseModel, AuditModel


class DCNeedPlan(AuditModel):
    __tablename__ = "dc_dispatch_need_plan"
    __table_args__ = ({"comment": "物料和辅料（飞走化工材料）需求任务"})

    product_type: Mapped[str] = mapped_column(String(50), comment="产品类型，机型")
    station: Mapped[str] = mapped_column(String(50), comment="工位")
    start: Mapped[datetime] = mapped_column(DateTime, nullable=True, comment="开始时间")
    end: Mapped[datetime] = mapped_column(DateTime, nullable=True, comment="结束时间")
    
    status: Mapped[str] = mapped_column(String(20), default='收集中', comment="需求单状态: 收集中、已下发、废弃")
    transport_id: Mapped[str] = mapped_column(String(50), nullable=True, comment="叫料单或配送单ID")
    plan_type: Mapped[str] = mapped_column(String(20), default='辅料需求', comment="计划类型：物料需求、辅料需求")

    remark: Mapped[str] = mapped_column(String(100), nullable=True, comment="备注")
    items: Mapped[list] = mapped_column(JSON, default=[], comment="需求项")

    transport_datetime: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True, comment='下发配送时间')

